package com.woniuxy.api;

import com.woniuxy.entity.Product;
import com.woniuxy.entity.ProductDTO;
import com.woniuxy.entity.utils.ResponseEntity;
import com.woniuxy.hystrix.FallbackFactoryCommand;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

//@FeignClient("hlf-product")
//(Hystrix): 最终方案: fallbackFactory 降级工厂
//@FeignClient(value = "hlf-product",fallbackFactory = FallbackFactoryCommand.class)
@FeignClient(value = "hlf-product")//有事务的地方，无法降级
@RequestMapping("/product")
public interface RemoteProductService {

    @RequestMapping("/{pid}")
    public ResponseEntity findOneById(@PathVariable("pid") Integer pid);


    @PutMapping("/")
    public ResponseEntity updateProduct(@RequestBody Product product);

        //通过传过来的数据，自己写参数
    //    @GetMapping("/findCondition")
//    public ResponseEntity findAllByNameOrPrice(@RequestParam("name") String name,@RequestParam("minPrice") double minPrice,
//                                               @RequestParam("maxPrice") double maxPrice);

    //方式二，通过传Map集合，在ServiceImpl中定义集合，得到数据封装
//    @GetMapping("/findCondition")
//    public ResponseEntity findAllByNameOrPrice1(@SpringQueryMap Map map);

    //方式三，定义一个类，专门获取数据，封装
    @GetMapping("/findCondition")
    public ResponseEntity findAllByNameOrPrice1(@SpringQueryMap ProductDTO productDTO);

}
